#define DEBUG
#include <cstdio>
#include <cmath>

using namespace std;

int sqr(int x) {
  return x*x;
}

class vector {
public:
  int x, y;
  
  vector(int _x, int _y) {
    x=_x, y=_y;
  }

  vector() {
    x=y=0;
  }

  int operator*(vector b) {
    return x*b.x+y*b.y;
  }

  vector operator*(int b) {
    return vector(x*b, y*b);
  }

  vector operator-(vector b) {
    return vector(x-b.x, y-b.y);
  }

  int len() {
    return sqr(x)+sqr(y);
  }
};

int solve(vector a, vector b) {
  if (a.len()>b.len()) {
    vector temp;
    temp=a, a=b, b=temp;
  }
  if (a*b<0) {
    a = a*(-1);
  }
  double len=sqrt(a.len()), t=a*b/sqrt(b.len());
  int x=floor(t/len), y=x+1;
  if (a.len()==0 || a*b/sqrt((long long)a.len()*b.len())<0.5) {
    return a.len();
  }
  if (t-x*len<=y*len-t) {
    return solve(b-a*x, a);
  } else {
    return solve(b-a*y, a);
  }
}

int main() {
  freopen("math.in", "r", stdin);
  freopen("math.out", "w", stdout);

  int x1, y1, x2, y2;
  for (; scanf("%d %d %d %d", &x1, &y1, &x2, &y2)!=EOF; ) {
    printf("%d\n", solve(vector(x1, y1), vector(x2, y2)));
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
